package com.eling.elcms.cater.webapp.controller;

import com.eling.elcms.cater.model.TravelAccount;
import com.eling.elcms.cater.service.ITravelAccountService;
import com.eling.elcms.charge.model.Account;
import com.eling.elcms.charge.model.AccountFlow;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.ordermanager.model.PreOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class TravelAccountController extends BaseFormController {
	@Autowired
	private ITravelAccountService travelAccountService;

	@RequestMapping("/api/cate/travelaccount/search*")
	@ResponseBody
	public List<TravelAccount> sreach(@ModelAttribute SearchCondition sc, @ModelAttribute TravelAccount cond) {
		sc.setQueryCondition(cond);
		return travelAccountService.search(sc);
	}

	@RequestMapping("/api/cate/travelaccount/query")
	@ResponseBody
	public List<TravelAccount> query(@ModelAttribute TravelAccount cond) {
		return travelAccountService.query(cond);
	}

	@RequestMapping("/api/cate/travelaccount/save1")
	@ResponseBody
	public TravelAccount save(@ModelAttribute @ModelFilling TravelAccount cond) {
		return travelAccountService.save(cond);
	}

	@RequestMapping("/api/cate/travelaccount/{pkTravelAccount}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkTravelAccount) {
		travelAccountService.remove(pkTravelAccount);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/cate/travelaccount/querycustomerattendantinfo")
	@ResponseBody
	public List<TravelAccount> queryCustomerAttendantInfo(@RequestParam (value = "cardId")String cardId){
		return travelAccountService.queryCustomerAttendantInfo(cardId);
	}

	//西软餐饮对接  根据消费卡查询账户
	@RequestMapping("/api/cate/account/querycustomerinfobycard")
	@ResponseBody
	public List<Account> queryCustomerInfoByCard(@RequestParam (value = "cardId")String cardId){
		return travelAccountService.queryCustomerInfoByCard(cardId);
	}

	//西软餐饮对接  根据idNumber查询账户
	@RequestMapping("/api/cate/account/querycustomerinfobyid")
	@ResponseBody
	public List<Account> queryCustomerInfoById(@RequestParam (value = "idNumber")String idNumber){
		return travelAccountService.queryCustomerInfoById(idNumber);
	}

	//西软餐饮对接  消费卡支付
	@RequestMapping("/api/cate/account/paybycard")
	@ResponseBody
	public AccountFlow payByCard(@ModelAttribute AccountFlow accountFlow,@RequestParam(value = "token",required = false) String token){
		return travelAccountService.payByCard(accountFlow,token);
	}


	//西软床位对接  消费卡支付
	@RequestMapping("/api/cate/account/paybedbycard")
	@ResponseBody
	public AccountFlow payBedByCard(@ModelAttribute AccountFlow accountFlow,@RequestParam(value = "token",required = false) String token){
		return travelAccountService.payBedByCard(accountFlow,token);
	}
}
